<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class site extends CI_Controller {

	function common($site_id){
		$this->load->model('article_model');

		$data = array();
		$data['where']['fgroup'] = 'common';
		$data['select'] 	= 1;
		$this->load->model('site_model');
		$vdata['site_list'] = $this->site_model->get_site_group_list($data);

  		$site = $this->site_model->get_site_obj($site_id);
  		$vdata['site'] = $site;

		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$this->load->view("site/common", $vdata);
	}

	function shouye($site_id){
		$this->load->model('article_model');

		$data = array();
		$data['where']['fgroup'] = 'shouye';
		$data['select'] 	= 1;
		$this->load->model('site_model');
		$vdata['site_list'] = $this->site_model->get_site_group_list($data);

  		$site = $this->site_model->get_site_obj($site_id);
  		$vdata['site'] = $site;

		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$this->load->view("site/shouye", $vdata);
	}

	function jiekuan($site_id){
		$this->load->model('article_model');

		$data = array();
		$data['where']['fgroup'] = 'jiekuan';
		$data['select'] 	= 1;
		$this->load->model('site_model');
		$vdata['site_list'] = $this->site_model->get_site_group_list($data);

  		$site = $this->site_model->get_site_obj($site_id);
  		$vdata['site'] = $site;

		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$this->load->view("site/jiekuan", $vdata);
	}

	function safe($url){
		$this->load->model('site_model');
		$vdata['active'] = "safe";
		$vdata['site_list'] = $this->site_model->get_site_url_list('safe');
		$url = isset($url)?$url :'hgyy';
		$site = $this->site_model->get_site_one(array('url'=>$url));
  		$vdata['site'] = $site;
  		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$vdata['url'] = 'safe';
  		$vdata['tab'] = 'safe';
  		$this->load->view("site/about", $vdata);
	}

    function base($url){
        $this->load->model('site_model');
        $vdata['site_list'] = $this->site_model->get_site_url_list('base');
        $url = isset($url)?$url:'base_reg';
        $site = $this->site_model->get_site_one(array('url'=>$url));
        $vdata['site'] = $site;
        $vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
        $vdata['url'] = 'base';
        $vdata['tab'] = 'base';
        $this->load->view("site/about", $vdata);
    }

    function invest($url){
        $this->load->model('site_model');
        $vdata['site_list'] = $this->site_model->get_site_url_list('invest');
        $url = isset($url)?$url:'invest_team';
        $site = $this->site_model->get_site_one(array('url'=>$url));
        $vdata['site'] = $site;
        $vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
        $vdata['url'] = 'invest';
        $vdata['tab'] = 'invest';
        $this->load->view("site/about", $vdata);
    }

    function finance($url){
        $this->load->model('site_model');
        $vdata['site_list'] = $this->site_model->get_site_url_list('finance');
        $url = isset($url)?$url:'invest_team';
        $site = $this->site_model->get_site_one(array('url'=>$url));
        $vdata['site'] = $site;
        $vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
        $vdata['url'] = 'finance';
        $vdata['tab'] = 'finance';
        $this->load->view("site/about", $vdata);
    }

    function safe2($url){
        $this->load->model('site_model');
        $vdata['site_list'] = $this->site_model->get_site_url_list('safe2');//得到其孩子链接
        $url = isset($url)?$url :'hgyy';
        $site = $this->site_model->get_site_one(array('url'=>$url));
        $vdata['site'] = $site;
        $vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
        $vdata['url'] = 'safe2';
        $vdata['tab'] = 'safe2';
        $this->load->view("site/about", $vdata);
    }

	function about_list($url){
		$this->load->model('site_model');
		$site = $this->site_model->get_site_one(array('url'=>$url));

		//接收参数
		$per_page 			= $this->input->get('per_page')?$this->input->get('per_page'):0;
		$txt = trim($this->input->get('txt'));
		$data = array();
		$data['where']['nid'] = $site['id'];
		$data['where']['txt'] = $txt;
		$data['page_size']  = ARTICLE_LIST_PAGE_SIZE;
		$data['page_start'] = (int)$per_page;
		$data['select'] 	= 1;
		$this->load->model('article_model');
		$vdata = $this->article_model->get_article_list($data);
		$vdata['site'] = $site;

		return $vdata;


	}

	function announcement($url){
		$this->load->model('site_model');
		$vdata['site_list'] = $this->site_model->get_site_url_list('announcement');
		$url = isset($url)?$url :'gonggao';
		$article_list = $this->about_list($url);
		//分页
		$this->load->library('pagination');

					$txt = trim($this->input->get('txt'));
		$config['base_url'] = "/site/announcement/$url.html?txt=".$txt;
		$config['total_rows'] = $article_list['article_count'];
		$config['per_page'] = ARTICLE_LIST_PAGE_SIZE;
		$this->pagination->initialize($config);

		$vdata['txt'] = $txt;
		$vdata['article_list']=$article_list['article_list'];
		$vdata['site'] = $article_list['site'];

		$vdata['fAction'] = "/site/about/$url.html";
		$vdata['url'] = 'announcement';
  		$vdata['tab'] = 'announcement';
		$vdata['title'] 		= $vdata['site']['title'].' - '.CON_KEYWORDS;

		$this->load->view('site/news_list', $vdata);
	}

	function about($url){
		$this->load->model('site_model');
		$vdata['active'] = "about";
		$vdata['site_list'] = $this->site_model->get_site_url_list('aboutus');
		$url = isset($url)?$url :'about';
		$smk = in_array($url, array('gonggao','media'));
		$site = $this->site_model->get_site_one(array('url'=>$url));
		$vdata['smk'] = $url;
		$vdata['leftmenu'] = 'single';
		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$vdata['url'] = 'about';
  		$vdata['tab'] = 'about';
		if($site['type_set'] == 1){
			$url = isset($url)?$url :'gonggao';
			$article_list = $this->about_list($url);
			//分页
			$this->load->library('pagination');

                        $txt = trim($this->input->get('txt'));
			$config['base_url'] = "/site/about/$url.html?txt=".$txt;
			$config['total_rows'] = $article_list['article_count'];
			$config['per_page'] = ARTICLE_LIST_PAGE_SIZE;
			$this->pagination->initialize($config);

			$vdata['txt'] = $txt;
			$vdata['article_list']=$article_list['article_list'];
			$vdata['site'] = $article_list['site'];

                        $vdata['fAction'] = "/site/about/$url.html";

			$this->load->view('site/news_list', $vdata);

		}else{
			//$site = $this->site_model->get_site_one(array('url'=>$url));
			$vdata['site'] = $site;
  			$this->load->view("site/about", $vdata);
		}




  		//$this->load->view("site/about", $vdata);
	}


	function view($article_id){
		$this->load->model('site_model');
		$this->load->model('article_model');
  		$article = $this->article_model->get_article_obj($article_id);

  		$vdata['site'] = $this->site_model->get_site_obj($article['nid']);

  		$site_list = $this->site_model->get_site_category_by_pid($vdata['site']['parent_id']);
  		$vdata['article'] = $article;
  		$vdata['site_list'] =$site_list;
  		$vdata['tab'] = 'announcement';
		$vdata['url'] = 'announcement';

  		$vdata['title']   = $article['title'].' - '.CON_WEBNAME;
  		//$vdata['keywords'] 	= $article['keywords'];
		//$vdata['description'] 	= $article['summary'];
  		$this->load->view("site/news", $vdata);
	}

	function business($url){
		$this->load->model('site_model');
		$vdata['site_list'] = $this->site_model->get_site_url_list('businessmodel');
		$url = isset($url)?$url :'guarantee';
		$site = $this->site_model->get_site_one(array('url'=>$url));
  		$vdata['site'] = $site;
  		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$vdata['url'] = 'business';
  		$vdata['tab'] = 'business';
  		$this->load->view("site/about", $vdata);
	}

	function vip($url){
		$this->load->model('site_model');
		$vdata['site_list'] = $this->site_model->get_site_url_list('vipexclusive');
		$url = isset($url)?$url :'customerservice';
		$site = $this->site_model->get_site_one(array('url'=>$url));
  		$vdata['site'] = $site;
  		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$vdata['url'] = 'vip';
  		$vdata['tab'] = 'vip';
  		$this->load->view("site/about", $vdata);
	}

	function danyue($url){
		$this->load->model('site_model');
        $vdata['site_list'] = $this->site_model->get_site_url_list('danyue');
		$url = isset($url)?$url :'shiyong';
		$site = $this->site_model->get_site_one(array('url'=>$url));
  		$vdata['site'] = $site;
  		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
  		$vdata['url'] = 'danyue';
  		$this->load->view("site/about", $vdata);
	}

	function help($url,$para2){
		$this->load->model('site_model');
		$vdata['active'] = "help";
		$vdata['second_site_list'] = $this->site_model->get_site_url_list('help');
        //参数校验及初始化 -- begin
		$url = isset($url)?$url :$vdata['second_site_list'][0]['url'];
        if(!$vdata['second_site_list'][0]['url']) {
            $this->js->go("/404");
        } elseif($para2 == null) {
            $tmp_third = $this->site_model->get_site_category_by_pid($vdata['second_site_list'][0]['id']);
            $para2 = $tmp_third[0]['url'];
        }
        //参数校验及初始化 -- end
		$site = $this->site_model->get_site_one(array('url'=>$para2));
//		$vdata['third_site_list'] = $this->site_model->get_site_category_by_pid($site['id']);
        $third_site_lists = array();
        foreach($vdata['second_site_list'] as $second_site) {
            $third_site_lists[$second_site['url']] = $this->site_model->get_site_category_by_pid($second_site['id']);
        }
        $vdata['third_site_lists'] = $third_site_lists;
        $vdata['site'] = $site;
  		$vdata['url'] = 'help';
  		$vdata['title'] 		= $site['title'].' - '.CON_KEYWORDS;
        $vdata['third_url'] = $para2;
  		$this->load->view("site/help", $vdata);
	}
}
